package com.itheima;

import com.itheima.student.Student;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.Date;
import java.util.Scanner;
import java.util.TreeMap;
//我加
public class demo02 {
    public static void main(String[] args) throws ParseException {
        /*Date date = new Date();
        System.out.println(date);

        long time = date.getTime();
        System.out.println(time);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");

        String s = simpleDateFormat.format(date);
        System.out.println(s);

        Date parse = simpleDateFormat.parse("2020年10月16日 21时39分20秒");
        System.out.println(parse);


        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入（yyyy年mm月dd天）");
        String s1 = scanner.nextLine();
        SimpleDateFormat format = new SimpleDateFormat("yyy年MM月dd天");
        Date parse1 = format.parse(s1);
        SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
        String format1 = simpleDateFormat1.format(parse1);
        System.out.println(format1);*/

        method();
    }

    private static void method() {
        TreeMap<Student, String> treeMap = new TreeMap<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getAge()-o2.getAge();
            }
        });
        treeMap.put(new Student("张三", 20), "上海");
        treeMap.put(new Student("李四", 17), "杭州");
        treeMap.put(new Student("王五", 19), "北京");
        treeMap.put(new Student("张三", 20), "上海");
        System.out.println(treeMap);
    }
}
